package com.approval.approvalapp.index.cygn;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.HysUseBean;
import com.approval.approvalapp.util.ErrorBeanUtil;
import com.approval.approvalapp.util.SpUtil;
import com.approval.approvalapp.util.base.BaseActivity;
import com.approval.approvalapp.util.net.NetRequsetUtil;
import com.approval.approvalapp.util.net.interfacepac.NetDownResponse;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class HysSyjlListActivity extends BaseActivity {


    @Bind(R.id.back_iv)
    ImageView backIv;
    @Bind(R.id.titleTv1)
    TextView titleTv1;
    @Bind(R.id.rvtitle_ll)
    LinearLayout rvtitleLl;
    @Bind(R.id.rv)
    RecyclerView rv;

    @Override
    public int getLayoutId() {
        return R.layout.activity_hys_syjl_list;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("areacode", SpUtil.getString(this, SpUtil.REGION_CODE, ""));
        NetRequsetUtil.getInstance().netRequestPostJson("v1/center/user_hui_list",
                jsonObject.toString(), new NetDownResponse() {
                    @Override
                    public void success(String str) {
                        List<HysUseBean> hysUseBeans = JSON.parseArray(str, HysUseBean.class);
                        rv.setLayoutManager(new LinearLayoutManager(HysSyjlListActivity.this));
                        HysSyjlAdapter hysSyjlAdapter = new HysSyjlAdapter();
                        rv.setAdapter(hysSyjlAdapter);
                        hysSyjlAdapter.setHysUseBeanList(hysUseBeans);
                    }

                    @Override
                    public void errowithresponse(String str) {
                        ErrorBeanUtil.getErrorMessage(str);
                    }

                    @Override
                    public void erro() {
                        ErrorBeanUtil.getErrorMessage(null);
                    }

                    @Override
                    public void finish() {

                    }
                });

    }



    @OnClick(R.id.back_iv)
    public void onViewClicked() {
        finish();
    }
}
